using System;
using System.Collections.Generic;
using System.Text;
using IBatisNet.DataAccess;
using IBatisNet.Common.Utilities;
using IBatisNet.DataAccess.Configuration;

namespace Bino.ExamOnline.Components
{
    public class Globals
    {        
        #region DaoManager

        private static IDaoManager _daoManager = null;
        private static readonly object _syncRoot = new object();

        public static IDaoManager GetDaoManger()
        {
            if (_daoManager == null)
            {
                lock (_syncRoot)
                {
                    DomDaoManagerBuilder builder = new DomDaoManagerBuilder();                    
                    ConfigureHandler handler = new ConfigureHandler(Reset);
                    builder.ConfigureAndWatch(handler);                    
                    IDaoManager daoManager = DaoManager.GetInstance("SqlMapDao");
                    _daoManager = daoManager;
                }
            }
            return _daoManager;
        }

        public static void Reset(object obj)
        {
            _daoManager = null;
        }

        #endregion
    }
}
